home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-PPC / IDE.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  11KB  |  311 lines

  1. /*
  2.  *  linux/include/asm-ppc/ide.h
  3.  *
  4.  *  Copyright (C) 1994-1996  Linus Torvalds & authors
  5.  */
  6.  
  7. /*
  8.  *  This file contains the ppc architecture specific IDE code.
  9.  */
  10.  
  11. #ifndef __ASMPPC_IDE_H
  12. #define __ASMPPC_IDE_H
  13.  
  14. #include <linux/config.h>
  15. /*
  16.  * On APUS, nearly everything comes from the m68k file
  17.  * -- Cort
  18.  */
  19. #ifdef CONFIG_APUS
  20. #include <linux/hdreg.h>
  21. #define ide_init_hwif_ports m68k_ide_init_hwif_ports 
  22. #include <asm-m68k/ide.h>
  23. #undef ide_init_hwif_ports
  24. #endif /* CONFIG_APUS */
  25.  
  26. #ifndef MAX_HWIFS
  27. #define MAX_HWIFS    4
  28. #endif
  29.  
  30. typedef unsigned int ide_ioreg_t;
  31.  
  32. extern int pmac_ide_ports_known;
  33. extern ide_ioreg_t pmac_ide_regbase[MAX_HWIFS];
  34. extern int pmac_ide_irq[MAX_HWIFS];
  35. extern void pmac_ide_probe(void);
  36.  
  37. extern int chrp_ide_ports_known;
  38. extern ide_ioreg_t chrp_ide_regbase[MAX_HWIFS];
  39. extern ide_ioreg_t chrp_idedma_regbase; /* one for both channels */
  40. extern unsigned int chrp_ide_irq;
  41. extern void chrp_ide_probe(void);
  42.  
  43. void ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq);
  44. void prep_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq);
  45. void mbx_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq);
  46. void pmac_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq);
  47. void chrp_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq);
  48. void ide_insw(ide_ioreg_t port, void *buf, int ns);
  49. void ide_outsw(ide_ioreg_t port, void *buf, int ns);
  50.  
  51. #undef insw
  52. #define insw(port, buf, ns)     do {                \
  53.     if ( _machine & (_MACH_chrp|_MACH_mbx) )        \
  54.          ide_insw((port)+_IO_BASE, (buf), (ns));      \
  55.     else if ( _machine & (_MACH_Pmac|_MACH_apus) )        \
  56.          ide_insw((port), (buf), (ns));          \
  57.     else                            \
  58.         /* this must be the same as insw in io.h!! */    \
  59.         _insw((unsigned short *)((port)+_IO_BASE), (buf), (ns)); \
  60. } while (0)
  61.      
  62. #undef outsw
  63. #define outsw(port, buf, ns)     do {                \
  64.     if ( _machine & (_MACH_chrp|_MACH_mbx) )         \
  65.         ide_outsw((port)+_IO_BASE, (buf), (ns));     \
  66.     else if ( _machine & (_MACH_Pmac|_MACH_apus) )        \
  67.         ide_outsw((port), (buf), (ns));         \
  68.     else                            \
  69.         /* this must be the same as outsw in io.h!! */    \
  70.         _outsw((unsigned short *)((port)+_IO_BASE), (buf), (ns)); \
  71. } while (0)
  72.  
  73. #ifndef CONFIG_APUS
  74. #ifdef __KERNEL__
  75.  
  76. #include <linux/hdreg.h>
  77. #include <linux/ioport.h>
  78. #include <asm/io.h>
  79.  
  80. #undef    SUPPORT_SLOW_DATA_PORTS
  81. #define    SUPPORT_SLOW_DATA_PORTS    0
  82. #undef    SUPPORT_VLB_SYNC
  83. #define SUPPORT_VLB_SYNC    0
  84.  
  85. #define ide__sti()    __sti()
  86.  
  87. static __inline__ int ide_default_irq(ide_ioreg_t base)
  88. {
  89.     if ( _machine == _MACH_Pmac )
  90.         return 0;
  91.     else if ( _machine == _MACH_mbx )
  92.         /* IRQ 14 when in legacy mode on MBX */
  93.         return 14;
  94.         else if ( _machine == _MACH_chrp) {
  95.                 if (chrp_ide_ports_known == 0) 
  96.             chrp_ide_probe();
  97.                 return chrp_ide_irq;
  98.         }
  99.     switch (base) {
  100.         case 0x1f0: return 13;
  101.         case 0x170: return 13;
  102.         case 0x1e8: return 11;
  103.         case 0x168: return 10;
  104.         default:
  105.             return 0;
  106.     }
  107. }
  108.  
  109. static __inline__ ide_ioreg_t ide_default_io_base(int index)
  110. {
  111. #if defined(CONFIG_BLK_DEV_IDE_PMAC)
  112.         if (_machine == _MACH_Pmac) {
  113.         return pmac_ide_regbase[index];
  114.     }
  115. #endif    
  116.     if (_machine == _MACH_mbx) return index;
  117.         if ( _machine == _MACH_chrp ) {
  118.                 if (chrp_ide_ports_known == 0)
  119.                         chrp_ide_probe();
  120.                 return chrp_ide_regbase[index];
  121.         }
  122.     switch (index) {
  123.         case 0:    return 0x1f0;
  124.         case 1:    return 0x170;
  125.         case 2: return 0x1e8;
  126.         case 3: return 0x168;
  127.         default:
  128.             return 0;
  129.     }
  130. }
  131.  
  132. static __inline__ int ide_check_region (ide_ioreg_t from, unsigned int extent)
  133. {
  134.     if ( (_machine == _MACH_Pmac) || (_machine == _MACH_mbx))
  135.         return 0;
  136.     return check_region(from, extent);
  137. }
  138.  
  139. static __inline__ void ide_request_region (ide_ioreg_t from, unsigned int extent, const char *name)
  140. {
  141.     if ( (_machine == _MACH_Pmac) || (_machine == _MACH_mbx) )
  142.         return;
  143.     request_region(from, extent, name);
  144. }
  145.  
  146. static __inline__ void ide_release_region (ide_ioreg_t from, unsigned int extent)
  147. {
  148.     if ( (_machine == _MACH_Pmac) || (_machine == _MACH_mbx) )
  149.         return;
  150.     release_region(from, extent);
  151. }
  152.  
  153. /* Convert the shorts/longs in hd_driveid from little to big endian;
  154.    chars are endian independent, of course, but strings need to be flipped.
  155.    (Despite what it says in drivers/block/ide.h, they come up as little endian...)
  156.    Changes to linux/hdreg.h may require changes here. */
  157. static __inline__ void ide_fix_driveid (struct hd_driveid *id) {
  158.   if ( _machine & (_MACH_chrp|_MACH_mbx|_MACH_Pmac) ) {     \
  159.         int i;
  160.         unsigned short *stringcast;
  161.         id->config         = __le16_to_cpu(id->config);
  162.         id->cyls           = __le16_to_cpu(id->cyls);
  163.         id->reserved2      = __le16_to_cpu(id->reserved2);
  164.         id->heads          = __le16_to_cpu(id->heads);
  165.         id->track_bytes    = __le16_to_cpu(id->track_bytes);
  166.         id->sector_bytes   = __le16_to_cpu(id->sector_bytes);
  167.         id->sectors        = __le16_to_cpu(id->sectors);
  168.         id->vendor0        = __le16_to_cpu(id->vendor0);
  169.         id->vendor1        = __le16_to_cpu(id->vendor1);
  170.         id->vendor2        = __le16_to_cpu(id->vendor2);
  171.         stringcast = (unsigned short *)&id->serial_no[0];
  172.         for (i=0; i<(20/2); i++)
  173.             stringcast[i] = __le16_to_cpu(stringcast[i]);
  174.         id->buf_type       = __le16_to_cpu(id->buf_type);
  175.         id->buf_size       = __le16_to_cpu(id->buf_size);
  176.         id->ecc_bytes      = __le16_to_cpu(id->ecc_bytes);
  177.         stringcast = (unsigned short *)&id->fw_rev[0];
  178.         for (i=0; i<(8/2); i++)
  179.             stringcast[i] = __le16_to_cpu(stringcast[i]);
  180.         stringcast = (unsigned short *)&id->model[0];
  181.         for (i=0; i<(40/2); i++)
  182.             stringcast[i] = __le16_to_cpu(stringcast[i]);
  183.         id->dword_io       = __le16_to_cpu(id->dword_io);
  184.         id->reserved50     = __le16_to_cpu(id->reserved50);
  185.         id->field_valid    = __le16_to_cpu(id->field_valid);
  186.         id->cur_cyls       = __le16_to_cpu(id->cur_cyls);
  187.         id->cur_heads      = __le16_to_cpu(id->cur_heads);
  188.         id->cur_sectors    = __le16_to_cpu(id->cur_sectors);
  189.         id->cur_capacity0  = __le16_to_cpu(id->cur_capacity0);
  190.         id->cur_capacity1  = __le16_to_cpu(id->cur_capacity1);
  191.         id->lba_capacity   = __le32_to_cpu(id->lba_capacity);
  192.         id->dma_1word      = __le16_to_cpu(id->dma_1word);
  193.         id->dma_mword      = __le16_to_cpu(id->dma_mword);
  194.         id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes);
  195.         id->eide_dma_min   = __le16_to_cpu(id->eide_dma_min);
  196.         id->eide_dma_time  = __le16_to_cpu(id->eide_dma_time);
  197.         id->eide_pio       = __le16_to_cpu(id->eide_pio);
  198.         id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy);
  199.         id->word69         = __le16_to_cpu(id->word69);
  200.         id->word70         = __le16_to_cpu(id->word70);
  201.         id->word71         = __le16_to_cpu(id->word71);
  202.         id->word72         = __le16_to_cpu(id->word72);
  203.         id->word73         = __le16_to_cpu(id->word73);
  204.         id->word74         = __le16_to_cpu(id->word74);
  205.         id->word75         = __le16_to_cpu(id->word75);
  206.         id->word76         = __le16_to_cpu(id->word76);
  207.         id->word77         = __le16_to_cpu(id->word77);
  208.         id->word78         = __le16_to_cpu(id->word78);
  209.         id->word79         = __le16_to_cpu(id->word79);
  210.         id->word80         = __le16_to_cpu(id->word80);
  211.         id->word81         = __le16_to_cpu(id->word81);
  212.         id->command_sets   = __le16_to_cpu(id->command_sets);
  213.         id->word83         = __le16_to_cpu(id->word83);
  214.         id->word84         = __le16_to_cpu(id->word84);
  215.         id->word85         = __le16_to_cpu(id->word85);
  216.         id->word86         = __le16_to_cpu(id->word86);
  217.         id->word87         = __le16_to_cpu(id->word87);
  218.         id->dma_ultra      = __le16_to_cpu(id->dma_ultra);
  219.         id->word89         = __le16_to_cpu(id->word89);
  220.         id->word90         = __le16_to_cpu(id->word90);
  221.         id->word91         = __le16_to_cpu(id->word91);
  222.         id->word92         = __le16_to_cpu(id->word92);
  223.         id->word93         = __le16_to_cpu(id->word93);
  224.         id->word94         = __le16_to_cpu(id->word94);
  225.         id->word95         = __le16_to_cpu(id->word95);
  226.         id->word96         = __le16_to_cpu(id->word96);
  227.         id->word97         = __le16_to_cpu(id->word97);
  228.         id->word98         = __le16_to_cpu(id->word98);
  229.         id->word99         = __le16_to_cpu(id->word99);
  230.         id->word100        = __le16_to_cpu(id->word100);
  231.         id->word101        = __le16_to_cpu(id->word101);
  232.         id->word102        = __le16_to_cpu(id->word102);
  233.         id->word103        = __le16_to_cpu(id->word103);
  234.         id->word104        = __le16_to_cpu(id->word104);
  235.         id->word105        = __le16_to_cpu(id->word105);
  236.         id->word106        = __le16_to_cpu(id->word106);
  237.         id->word107        = __le16_to_cpu(id->word107);
  238.         id->word108        = __le16_to_cpu(id->word108);
  239.         id->word109        = __le16_to_cpu(id->word109);
  240.         id->word110        = __le16_to_cpu(id->word110);
  241.         id->word111        = __le16_to_cpu(id->word111);
  242.         id->word112        = __le16_to_cpu(id->word112);
  243.         id->word113        = __le16_to_cpu(id->word113);
  244.         id->word114        = __le16_to_cpu(id->word114);
  245.         id->word115        = __le16_to_cpu(id->word115);
  246.         id->word116        = __le16_to_cpu(id->word116);
  247.         id->word117        = __le16_to_cpu(id->word117);
  248.         id->word118        = __le16_to_cpu(id->word118);
  249.         id->word119        = __le16_to_cpu(id->word119);
  250.         id->word120        = __le16_to_cpu(id->word120);
  251.         id->word121        = __le16_to_cpu(id->word121);
  252.         id->word122        = __le16_to_cpu(id->word122);
  253.         id->word123        = __le16_to_cpu(id->word123);
  254.         id->word124        = __le16_to_cpu(id->word124);
  255.         id->word125        = __le16_to_cpu(id->word125);
  256.         id->word126        = __le16_to_cpu(id->word126);
  257.         id->word127        = __le16_to_cpu(id->word127);
  258.         id->security       = __le16_to_cpu(id->security);
  259.         for (i=0; i<127; i++)
  260.             id->reserved[i] = __le16_to_cpu(id->reserved[i]);
  261.     }
  262. }
  263.  
  264. #undef inb
  265. #define inb(port)    \
  266.     in_8((unsigned char *)((port) + \
  267.                    ((_machine==_MACH_Pmac)? 0: _IO_BASE) ) )
  268. #undef inb_p
  269. #define inb_p(port)    inb(port)
  270.  
  271. #undef outb
  272. #define outb(val, port)    \
  273.     out_8((unsigned char *)((port) + \
  274.                 ((_machine==_MACH_Pmac)? 0: _IO_BASE) ), (val) )
  275. #undef outb_p
  276. #define outb_p(val, port)    outb(val, port)
  277.  
  278. typedef union {
  279.     unsigned all            : 8;    /* all of the bits together */
  280.     struct {
  281.         unsigned bit7        : 1;    /* always 1 */
  282.         unsigned lba        : 1;    /* using LBA instead of CHS */
  283.         unsigned bit5        : 1;    /* always 1 */
  284.         unsigned unit        : 1;    /* drive select number, 0/1 */
  285.         unsigned head        : 4;    /* always zeros here */
  286.     } b;
  287. } select_t;
  288.  
  289. static __inline__ int ide_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
  290.             unsigned long flags, const char *device, void *dev_id)
  291. {
  292.     return request_irq(irq, handler, flags, device, dev_id);
  293. }            
  294.  
  295. static __inline__ void ide_free_irq(unsigned int irq, void *dev_id)
  296. {
  297.     free_irq(irq, dev_id);
  298. }
  299.  
  300. /*
  301.  * The following are not needed for the non-m68k ports
  302.  */
  303. #define ide_ack_intr(base, irq)        (1)
  304. #define ide_release_lock(lock)        do {} while (0)
  305. #define ide_get_lock(lock, hdlr, data)    do {} while (0)
  306.  
  307. #endif /* __KERNEL__ */
  308. #endif /* CONFIG_APUS */
  309.  
  310. #endif /* __ASMPPC_IDE_H */
  311.